#ifndef __PCRESOURCE_H_
#define _PCRESOURCE_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#include <string>
#include <string.h>
#include <thread>
#include <mutex>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "PCResource_gui.h"

using namespace std;

class PCResource;

class PCResource
{

public:
    
private:
    thread *pthread;         //独立于UI的线程
    mutex *ui_mutex;        //UI资源互斥锁
    bool thread_exit_flag;          //线程退出标志
    int socket_fd;          //socket描述符
    string ip_addr;         //服务器ip地址(点分十进制)
    struct sockaddr_in server_addr;     //服务器地址
public:
    PCResource(string &ipaddr, int port, exit_cb_t exit_cb, mutex &UIMutex);
    ~PCResource();
    
    int GetData(string &info);
    PCResInfo AnalyticData(string &info);

    mutex *getUIMutex(void) const { return ui_mutex; }
    const bool getExitFlag() const { return thread_exit_flag; }
};



#endif